package thread;

//饿汉形式的单例模式
class Singleton{
    private static Singleton instance = new Singleton();

    //后续统一通过这个方法获取这个唯一的实例
    public static Singleton getInstance(){
        return instance;
    }

    //方法私有，不能创建更多的实例
    private Singleton(){

    }
}
public class Demo19 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1 == s2);
    }
}
